import 'package:flutter/material.dart';
import 'package:flutter_crud_test_amir_rabbani/core/resource/my_colors.dart';
import 'package:flutter_crud_test_amir_rabbani/core/resource/typography.dart';
import 'package:flutter_crud_test_amir_rabbani/core/widgets/base_stateless.dart';
import 'package:flutter_crud_test_amir_rabbani/core/widgets/clickable_container.dart';

class PrimaryButton extends BaseStateless {
  String text;
  Function()? onTap;
  Alignment? alignment;
  double borderRadius;
  double? fontSize, height;
  Widget? leftIcon;
  EdgeInsets? padding;

  PrimaryButton(
    this.text,
    this.onTap, {
    super.key,
    this.leftIcon,
    this.alignment = Alignment.center,
    this.padding,
    this.height = 48,
    this.borderRadius = 8,
    this.fontSize,
  });

  @override
  Widget buildState(BuildContext context) {
    return ClickableContainer(
      height: height,
      padding: padding ?? const EdgeInsets.symmetric(horizontal: 20),
      onTap: onTap,
      alignment: alignment,
      color: Theme.of(context).primaryColor,
      borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          Text(text,
              style: textTheme.bodyLarge
                  ?.copyWith(color: CustomColors.tertiaryText)),
          if (leftIcon != null) const SizedBox(width: 10),
          if (leftIcon != null) leftIcon!,
        ],
      ),
    );
  }
}
